<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<script type="text/javascript" src="${ctx}/scripts/upload/jquery.MultiFile.js"></script>
<script type="text/javascript" src="${ctx}/scripts/jquery/jquery.form.js"></script>
		
<%@ page import="com.msmall.base.util.ConstantDB" language="java"%>
<%@ page import="com.msmall.community.space.util.SpaceConstants" language="java"%>
<c:set var="UNLOCK_STATUS" value="<%=ConstantDB.UNLOCK_STATUS%>"></c:set>
<c:set var="LOCK_STATUS" value="<%=ConstantDB.LOCK_STATUS%>"></c:set>
<c:set var="REPLY" value="<%=ConstantDB.REPLY%>"></c:set>
<c:set var="SPACE_WIDGET_PART_ALBUM" value="<%=SpaceConstants.SPACE_WIDGET_PART_ALBUM%>"></c:set>
<div class="spaw730nav">
	<p class="sHB00 fl" onclick="spaceIndexNav(<c:out value='${SPACE_WIDGET_PART_ALBUM}'/>)">
		我的相册
	</p>
	<p class="fr" style="margin-top:-5px;margin-right:400px">
		<a style="float:left;" class="but82" id="a_space_album_updload" href="javascript:spaceAlbumUpload()">上传照片</a>
		<a style="float:left;margin-left:15px;" class="but82" id="a_space_album" href="javascript:createAlbum()">创建相册</a>
	</p>
</div>
<div class="spalistphoto">
	<form id="album_photo_upload" action="<c:url value='/photo/save.do'/>" method="post" enctype="multipart/form-data"> 
	上传到:
	<select name="albumid">
		<c:forEach var="varAlbum" items="${albums}" varStatus="status">
			<option value="${varAlbum.albumid}" <c:if test="${varAlbum.albumid==albumid}">selected="selected"</c:if>>
				<c:out value="${varAlbum.title}"></c:out>
				<c:if test="${varAlbum.lockStatus == LOCK_STATUS}">
				--已设置密码
				</c:if>
		</c:forEach>
	</select>
	允许评论：<input name="enabledReply" type="checkbox" value="${REPLY}">
	<br>
	为了你上传速度，每次最多上传5张照片<br>
	<input class="multifile" type="file" name="images" maxlength="5" accept="gif|jpg|png|bmp">
	<br>
	<button class="btn1" type="submit">上传</button>
	</form>
</div>
<div class="pagediv martop10 tc clear">
</div>
<script>
$(document).ready(function(){
	$("#album_photo_upload").ajaxForm({
		dataType:'xml', 
		type:'post',
		success: processUploadResult
	});
	
	$(".multifile").MultiFile();
});

function processUploadResult(result){
	if($(result).find('result').text().toUpperCase().indexOf("TRUE") >= 0){
		var albumid = $(result).find('content').text();
		spaceAlbumList(albumid);
		alert("上传成功！");
	}else{
		alert("上传出错！请重新上传！");
	}
}
</script>